// -----------------------------------------------------------------------
// <copyright file="RequirementsListEN.cs" company="VDC-IT" author="LTDUC">
//      Copyright (c) VDC-IT. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------

namespace VDC.VONE.ENTITIES
{
    using System;
    using System.Collections.Generic;
    using System.Data.SqlClient;
    using Microsoft.ApplicationBlocks.Data;
    using VDC.COMMON;
    
    /// <summary>
    /// Class RequirementsList
    /// </summary>
    public class RequirementsListEN : EntityEN
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="RequirementsListEN" /> class
        /// </summary>
        public RequirementsListEN()
        {
            this.RequirementsListId = 0;
            this.Name = string.Empty;
        }

        /// <summary>
        /// Gets or sets RequirementsListId
        /// </summary>
        public int RequirementsListId { get; set; }

        /// <summary>
        /// Gets or sets Name
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// Gets ProfileTypeRequirementsLists
        /// </summary>
        public IList<ProfileTypeRequirementsListEN> ProfileTypeLegalGroundsLists
        {
            get
            {
                try
                {
                    IList<ProfileTypeRequirementsListEN> lstProfileTypeLegalGroundsList = new List<ProfileTypeRequirementsListEN>();
                    var reader = SqlHelper.ExecuteReader(SqlHelper.ConnectionString, Constants.StorepProcedure.VOneProfileTypeRequirementsListGetByRequirementsListId, this.RequirementsListId);
                    while (reader.Read())
                    {
                        ProfileTypeRequirementsListEN profileTypeRequirementsList = new ProfileTypeRequirementsListEN();
                        if (!reader.IsDBNull(0))
                        {
                            profileTypeRequirementsList.ProfileTypeRequirementsListId = reader.GetInt32(0);
                        }

                        if (!reader.IsDBNull(1))
                        {
                            profileTypeRequirementsList.RequirementsListId = reader.GetInt32(1);
                        }

                        if (!reader.IsDBNull(2))
                        {
                            profileTypeRequirementsList.ProfileTypeId = reader.GetInt32(2);
                        }

                        lstProfileTypeLegalGroundsList.Add(profileTypeRequirementsList);
                    }

                    reader.Close();
                    reader.Dispose();
                    return lstProfileTypeLegalGroundsList;
                }
                catch (SqlException ex)
                {
                    throw new Exception(ex.ToString());
                }
            }
        }
    }
}
